package com.zego.wawaji.ui.bean.user;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 用户信息基类
 */
public class UserBasic extends BaseData implements Parcelable {
    public long uid;             // 用户Id
    private String avatar;       // 头像
    private String nickname;     // 昵称
    private String mobile;       // 个人资料手机号码

    @Override
    public void parseJson(String s) {
        JSONObject detailObject = getJsonObject(s);
        this.setUid(detailObject.optLong("Id"));
        this.setAvatar(detailObject.optString("Avatar"));
        this.setNickname(detailObject.optString("NickName"));
    }

    // ------------ Getter  Setter --------------

    public String getAvatar() {
        return avatar;  // 拼接头像地址
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public long getUid() {
        return uid;
    }

    public void setUid(long uid) {
        this.uid = uid;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.nickname);
        dest.writeLong(this.uid);
        dest.writeString(this.mobile);
        dest.writeString(this.avatar);
    }

    public UserBasic() {
    }

    protected UserBasic(Parcel in) {
        this.nickname = in.readString();
        this.uid = in.readLong();
        this.mobile = in.readString();
        this.avatar = in.readString();
    }
}
